package concurrent;

/**
 * TODO 简单说明
 *
 * @author yangyang
 * @date 2017/7/4 18:07
 * @email kekecany@163.com
 */
public class MultiLock {

    public synchronized void f1(int count) {
        if (count-- > 0) {
            System.out.println("f1 calling f2 in count: " + count);
            f2(count);
        }
    }

    public synchronized void f2(int count) {
        if (count-- > 0) {
            System.out.println("f2 calling f1 in count: " + count);
            f1(count);
        }

    }

    public static void main(String[] args) {
        MultiLock multiLock = new MultiLock();
        new Thread(() -> {
            multiLock.f1(10);
        }).start();
    }
}
